package com.xiaoyu.lingdian.service.impl;

import java.util.Map;
import java.util.List;
import java.util.HashMap;
import com.xiaoyu.lingdian.core.mybatis.page.Page;
import com.xiaoyu.lingdian.core.mybatis.page.PageRequest;
import com.xiaoyu.lingdian.service.CoreRepairOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xiaoyu.lingdian.core.mybatis.dao.MyBatisDAO;
import com.xiaoyu.lingdian.entity.CoreRepairOrder;

@Service("coreRepairOrderService")
public class CoreRepairOrderServiceImpl implements CoreRepairOrderService {

	@Autowired
	private MyBatisDAO myBatisDAO;

	@Override
	public boolean insertCoreRepairOrder(CoreRepairOrder coreRepairOrder) {
		myBatisDAO.insert(coreRepairOrder);
		return true;
	}

	@Override
	public boolean updateCoreRepairOrder(CoreRepairOrder coreRepairOrder) {
		myBatisDAO.update(coreRepairOrder);
		return true;
	}

	@Override
	public boolean deleteCoreRepairOrder(CoreRepairOrder coreRepairOrder) {
		myBatisDAO.delete(coreRepairOrder);
		return true;
	}

	private static final String DELETEBATCH_COREREPAIRORDER_BY_IDS="deleteBatchCoreRepairOrderByIds";
	@Override
	public boolean deleteBatchByIds(List<String> list ) {
		Map<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("list", list);
		myBatisDAO.delete(DELETEBATCH_COREREPAIRORDER_BY_IDS,hashMap);
		return true;
	}

	@Override
	public CoreRepairOrder getCoreRepairOrder(CoreRepairOrder coreRepairOrder) {
		return (CoreRepairOrder) myBatisDAO.findForObject(coreRepairOrder);
	}

	private static final String FIND_COREREPAIRORDER_FOR_LISTS="findCoreRepairOrderForLists";

	@SuppressWarnings("unchecked")
	@Override
	public List<CoreRepairOrder> findCoreRepairOrderList() {
		return myBatisDAO.findForList(FIND_COREREPAIRORDER_FOR_LISTS, null);
	}

	private static final String FIND_COREREPAIRORDER_FOR_PAGES="findCoreRepairOrderForPages";

	@SuppressWarnings("unchecked")
	@Override
	public Page<CoreRepairOrder> findCoreRepairOrderPage(int pageNum, int pageSize, String crrorUser, String crusrName, Integer crrorStatus) {
		Map<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("crrorUser", crrorUser);
		hashMap.put("crusrName", crusrName);
		hashMap.put("crrorStatus", crrorStatus);
		return myBatisDAO.findForPage(FIND_COREREPAIRORDER_FOR_PAGES, new PageRequest(pageNum, pageSize, hashMap));
	}

//<=================定制内容开始==============
//==================定制内容结束==============>

}